<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Attribute extends Model
{
    use SoftDelete;
    // 设置获取器
    public function getAttrTypeAttr($value)
    {
        $status = [
            '0' => '唯一属性',
            '1' => '单选属性'
        ];

        return $status[$value];
    }

    public function getAttrInputTypeAttr($value)
    {
        $status = [
            '0' => '输入框',
            '1' => '下拉列表',
            '2' => '多选框'
        ];

        return $status[$value];
    }

    // 获取所有的属性
    public static function getAttrtype(){

        return self::table("think_attribute")
            ->alias('a')
            ->field('a.*,t.type_name')
            ->join('think_type t','a.type_id = t.id')
            ->select();

    }
}
